
local indata LAD\Data
local infile LAD\Data_Cleaning

use "`indata'\LAD_Crowdout.dta", clear

do "`infile'\LAD_Commands_filtering.do"

*Focus on savers within the relevant bandwidth
keep if empinc>=-6000 & empinc<6000

*Non-Unionized RPP Non-Members do not satisfy the Test of Running Variable and are excluded
keep if dues>0
*Focus on savers with strictly positive RRSP contributions
keep if rspcont>0
keep if rspcont<rspdlc & (penadjl+rspcont)<contlimit

*Creates the bins for current income, for graphing purposes
gen incgrp=0
local counter=-6000
forvalues i=1(1)29 {
	local counter=`counter'+400
	replace incgrp=incgrp+1 if empinc>=`counter'
}

*-----------------------------
*1) RPP employer contributions
*-----------------------------

preserve
keep if penadj>0

reg rppempcont empinc empinc_kink
predict rppempcont_hat, xb
reg rppempcont empinc if empinc<=0
predict rppempcont_hat_cfl, xb

egen grp=group(incgrp)
collapse (mean) rppempcont rppempcont_hat rppempcont_hat_cfl incgrp year, by(grp)
replace incgrp=((incgrp-15)/15)*6000
list rppempcont incgrp, noobs clean

graph twoway (scatter rppempcont incgrp, msize(small) mcolor(gs5) msymbol(Oh)) (lfit rppempcont_hat incgrp if incgrp<=0, lcolor(gray)) (lfit rppempcont_hat incgrp if incgrp>=0, lcolor(gray)) (lfit rppempcont_hat_cfl incgrp if incgrp>=0, lcolor(gray) lpattern(dash)), xscale(r(-6300(3000)6299)) xlabel(-6000(3000)6299, labgap(2) tposition(inside) format(%12.0gc)) xtitle("Employment income relative to the kink", margin(0 0 0 2)) xline(6299, lwidth(thin) lcolor(black)) yscale(r(1400(300)2600)) ylabel(1400(300)2600, labgap(2) angle(horizontal) noticks glcolor(gs13) format(%12.0gc)) yline(2600, lwidth(thin) lcolor(black)) ytitle("") graphregion(color(white)) bgcolor(white) plotregion(margin(0)) title("Contributions", justification(left) placement(west) margin(-8 0 5 0) tstyle(body)) legend(off) scale(1.2)
graph export RPP_Employer_Contributions.eps, replace

restore

*---------------------------
*2) RPP worker contributions
*---------------------------

preserve
keep if penadj>0

reg rppcont empinc empinc_kink
predict rppcont_hat, xb
reg rppcont empinc if empinc<=0
predict rppcont_hat_cfl, xb

egen grp=group(incgrp)
collapse (mean) rppcont rppcont_hat rppcont_hat_cfl incgrp year, by(grp)
replace incgrp=((incgrp-15)/15)*6000
list rppcont incgrp, noobs clean

graph twoway (scatter rppcont incgrp, msize(small) mcolor(gs5) msymbol(Oh)) (lfit rppcont_hat incgrp if incgrp<=0, lcolor(gray)) (lfit rppcont_hat incgrp if incgrp>=0, lcolor(gray)) (lfit rppcont_hat_cfl incgrp if incgrp>=0, lcolor(gray) lpattern(dash)), xscale(r(-6300(3000)6299)) xlabel(-6000(3000)6299, labgap(2) tposition(inside) format(%12.0gc)) xtitle("Employment income relative to the kink", margin(0 0 0 2)) xline(6299, lwidth(thin) lcolor(black)) yscale(r(1100(200)1900)) ylabel(1100(200)1900, labgap(2) angle(horizontal) noticks glcolor(gs13) format(%12.0gc)) yline(1900, lwidth(thin) lcolor(black)) ytitle("") graphregion(color(white)) bgcolor(white) plotregion(margin(0)) title("Contributions", justification(left) placement(west) margin(-8 0 5 0) tstyle(body)) legend(off) scale(1.2)
graph export RPP_Worker_Contributions.eps, replace

restore

*-------------------------------------
*3) RRSP contributions for RPP members
*-------------------------------------

preserve
keep if penadj>0

reg rspcont empinc empinc_kink
predict rspcont_hat, xb
reg rspcont empinc if empinc<=0
predict rspcont_hat_cfl, xb

egen grp=group(incgrp)
collapse (mean) rspcont rspcont_hat rspcont_hat_cfl incgrp year, by(grp)
replace incgrp=((incgrp-15)/15)*6000
list rspcont incgrp, noobs clean

graph twoway (scatter rspcont incgrp, msize(small) mcolor(gs5) msymbol(Oh)) (lfit rspcont_hat incgrp if incgrp<=0, lcolor(gray)) (lfit rspcont_hat incgrp if incgrp>=0, lcolor(gray)) (lfit rspcont_hat_cfl incgrp if incgrp>=0, lcolor(gray) lpattern(dash)), xscale(r(-6300(3000)6299)) xlabel(-6000(3000)6299, labgap(2) tposition(inside) format(%12.0gc)) xtitle("Employment income relative to the kink", margin(0 0 0 2)) xline(6299, lwidth(thin) lcolor(black)) yscale(r(2000(150)2600)) ylabel(2000(150)2600, labgap(2) angle(horizontal) noticks glcolor(gs13) format(%12.0gc)) yline(2600, lwidth(thin) lcolor(black)) ytitle("") graphregion(color(white)) bgcolor(white) plotregion(margin(0)) title("Contributions", justification(left) placement(west) margin(-8 0 5 0) tstyle(body)) legend(off) scale(1.2)
graph export RRSP_Contributions_yesRPP.eps, replace

restore

*-----------------------------------------
*4) RRSP contributions for RPP non-members
*-----------------------------------------

preserve
keep if penadj==0

reg rspcont empinc empinc_kink
predict rspcont_hat, xb
reg rspcont empinc if empinc<=0
predict rspcont_hat_cfl, xb

egen grp=group(incgrp)
collapse (mean) rspcont rspcont_hat rspcont_hat_cfl incgrp year, by(grp)
replace incgrp=((incgrp-15)/15)*6000
list rspcont incgrp, noobs clean

graph twoway (scatter rspcont incgrp, msize(small) mcolor(gs5) msymbol(Oh)) (lfit rspcont_hat incgrp if incgrp<=0, lcolor(gray)) (lfit rspcont_hat incgrp if incgrp>=0, lcolor(gray)) (lfit rspcont_hat_cfl incgrp if incgrp>=0, lcolor(gray) lpattern(dash)), xscale(r(-6300(3000)6299)) xlabel(-6000(3000)6299, labgap(2) tposition(inside) format(%12.0gc)) xtitle("Employment income relative to the kink", margin(0 0 0 2)) xline(6299, lwidth(thin) lcolor(black)) yscale(r(2400(400)4000)) ylabel(2400(400)4000, labgap(2) angle(horizontal) noticks glcolor(gs13) format(%12.0gc)) yline(4000, lwidth(thin) lcolor(black)) ytitle("") graphregion(color(white)) bgcolor(white) plotregion(margin(0)) title("Contributions", justification(left) placement(west) margin(-8 0 5 0) tstyle(body)) legend(off) scale(1.2)
graph export RRSP_Contributions_noRPP.eps, replace

exit